package com.itheima.springbootwebtlias.controller;

import com.itheima.springbootwebtlias.pojo.Result;
import com.itheima.springbootwebtlias.util.AliyunOSSOperator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

//处理文件上传的处理器
@Slf4j
@RestController
public class UploadController {

    @Autowired
    private AliyunOSSOperator aliyunOSSOperator;

    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws Exception {

        log.info("文件上传，文件名：{}",file);

        //2.
        String image = aliyunOSSOperator.upload(file.getBytes(), file.getOriginalFilename());


        //3.
        return Result.success(image);



/**
 *
 *
 *
  */


    }
}
